package com.ruoyi.ade.llm.chunk;

import com.ruoyi.ade.llm.chunk.pattern.PatternCondition;

import java.util.ArrayList;
import java.util.List;

/**
 * 根据规则表达式 切割的请求
 */
public class ChunkByPatternRequest extends IAbstractChunkRequest{

    private List<PatternCondition> patterns;
    private final String END_PATTERN = "[，,;.。、；：:\\d\\s]";  //标点符号  空格 数字
    private final String START_PATTERN = "[.。；:;：]";  //开始模式     句号、分号、冒号 开头

    public ChunkByPatternRequest(){
        patterns = new ArrayList<>();
        patterns.add(new PatternCondition("([考]?[虑]?[^，,;.。、；：:]*?药物性[^，,;.。、；：:]+?)" + END_PATTERN));
        patterns.add(new PatternCondition("(患[者儿][^，,;.。、；：:]*?出现.*?暂停.*?)" + END_PATTERN));

        //能一句话说完的 就要一句话说完
        patterns.add(new PatternCondition(
                "(患[者儿][^，,;.。、；：:]*?考虑药物不良反应所致)" + END_PATTERN,
                "(患[者儿][^。]*?考虑药物不良反应所致)" + END_PATTERN,
                "(患[者儿][^，,;.。、；：:]*?考虑[^，,;.。、；：:]*?不良反应[^，,;.。、；：:]*?)" + END_PATTERN,
                "(患[者儿][^。]*?考虑[^，,;.。、；：:]*?不良反应[^，,;.。、；：:]*?)" + END_PATTERN,
                "(患[者儿][^，,;.。、；：:]*?考虑[^，,;.。、；：:]*?(药物|所致|过敏|导致)[^，,;.。、；：:]*?)" + END_PATTERN,
                "(患[者儿][^.。]*?考虑[^，,;.。、；：:]*?(药物|所致|过敏|导致)[^，,;.。、；：:]*?)" + END_PATTERN,
                "[。；:;：]([^。；:：]*?考虑[^，,;.。、；：:]*?(药物|所致|过敏|导致)[^，,;.。、；：:]*?)" + END_PATTERN));

        //
        patterns.add(new PatternCondition("(患[者儿][^，,;.。、；：:\\d\\s]*?(注射|静滴|输注|服用|口服|输液)[^.。]*?(出现|突发|偶发|突现|发生)[^.。]*?考虑[^.。]*?)" + END_PATTERN,
                "(患[者儿][^.。]*?(注射|静滴|输注|服用|口服|输液)[^.。]*?(出现|突发|偶发|突现|发生)[^.。]*?考虑[^.。]*?)" + END_PATTERN,
                "(患[者儿][^，,;.。、；：:\\d\\s]*?(注射|静滴|输注|服用|口服|输液)[^.。]*?(出现|突发|偶发|突现|发生)[^.。]+?)" + END_PATTERN,
                "(患[者儿][^.。]*?(注射|静滴|输注|服用|口服|输液)[^.。]*?(出现|突发|偶发|突现|发生)[^.。]+?)" + END_PATTERN,
                "(患[者儿][^.。]*?[^.。]*?(出现|突发|偶发|突现|发生)[^.。]+?考虑[^.。]*?)" + END_PATTERN,
                "(患[者儿][^.。]*?[^.。]*?(出现|突发|偶发|突现|发生)[^.。]+?)" + END_PATTERN,
                "[。；:;：]((出现|突发|偶发|突现|发生)[^.。]*?考虑[^，,;.。、；：:]*?(过敏|所致|有关|相关)[^，,;.。、；：:]*?)" + END_PATTERN));

        //有关相关模式
        patterns.add(new PatternCondition("[：.。；:;\\s]([^：。；:;\\s]*?考虑[^，,;.。、；：:]*?(有关|相关)[^，,;.。、；：:]*?)" + END_PATTERN));

        //停药 模式
        patterns.add(new PatternCondition(
                "(患[者儿][^，,;.。、；：:]*?(出现|突发|偶发|突现|发生)[^。]*?[,，](予以停药|停止|停)[^，,;.。、；：:]*?)" + END_PATTERN,
                "(患[者儿][^，,;.。、；：:]*?(出现|突发|偶发|突现|发生)[^。]*?(予以停药|停止|停)[^，,;.。、；：:]*?)" + END_PATTERN,
                "(患[者儿][^。.]*?(出现|突发|偶发|突现|发生)[^。]*?[,，](予以停药|停止|停)[^，,;.。、；：:]*?)" + END_PATTERN,
                "(患[者儿][^。.]*?(出现|突发|偶发|突现|发生)[^。]*?(予以停药|停止|停)[^，,;.。、；：:]*?)" + END_PATTERN,
                "(患[者儿][^，,;.。、；：:]*?[,，](予以停药|停止|停)[^，,;.。、；：:]*?)" + END_PATTERN,
                "(患[者儿][^，,;.。、；：:]*?(予以停药|停止|停)^，,;.。、；：:]*?)" + END_PATTERN,
                "(患[者儿][^，,;.。、；：:]*?(停药|停止|停)[^，,;.。、；：:]*?)" + END_PATTERN,
                "(患[者儿][^.。]*?(停药|停止|停)[^，,;.。、；：:]*?)" + END_PATTERN));

        //化疗类
        patterns.add(new PatternCondition("(化疗后(出现|突发|偶发|突现|发生)[^，,;.。、；：:]*?)" + END_PATTERN,
                "[;。；:：]([^。.]*?考虑[^，,;.。、；：:]*?化疗[^，,;.。、；：:]*?)" + END_PATTERN));

        //异常类
        patterns.add(new PatternCondition("[.。；:;：]([^\\s\\d，,;.。、；：:]*?异常[^，,;.。、；：:]*?(有关|相关)[^，,;.。、；：:]*?)" + END_PATTERN));

        //过敏性
        patterns.add(new PatternCondition("[，,;.。、；：:]([^，,;.。、；：:]*?过敏可能性大[^，,;.。、；：:]*?)" + END_PATTERN));

    }

    public List<PatternCondition> getPatterns() {
        return patterns;
    }
}
